package com.test;

import java.io.File;
import java.io.FileOutputStream;

import com.barcodelib.barcode.Linear;
import com.lowagie.text.Document;
import com.lowagie.text.Image;
import com.lowagie.text.pdf.PdfWriter;

public class CreatePDF {

	/**
	 *
	 * @param args
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception {
	    
	    

		String barcode_path = "D:/workspace_PHP/testBarcode/BarImage/barcode.gif";
		String pdf_path = "D:/workspace_PHP/testBarcode/pdf/Chap0101.pdf";


		File file = new File(barcode_path);
		if (file.exists()) file.delete();

		createBarcode(barcode_path);

		Document document = new Document();
		PdfWriter.getInstance(document, new FileOutputStream(pdf_path));
		document.open();
		Image gif = Image.getInstance(barcode_path);
		document.add(gif);
		document.close();

	}

	/**
	 *
	 * @param barcode_path
	 *            �o�[�R�[�h�̃p�X
	 * @throws Exception
	 *             �ُ�
	 */
	private static void createBarcode(String barcode_path) throws Exception {
		Linear linear = new Linear();
		linear.setData("3453");
		linear.setType(Linear.CODE39);
		linear.renderBarcode(barcode_path);
	}
}
